package com.cn.ZhiKeDianShang.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import com.cn.ZhiKeDianShang.R;
import com.cn.ZhiKeDianShang.base.RecycleAndListBaseAdapter.RecycleBaseAdapter.RecycleBaseViewHolder;
import com.cn.ZhiKeDianShang.base.RecycleAndListBaseAdapter.RecycleBaseAdapter.RecycleListBaseAdapter;
import com.cn.ZhiKeDianShang.model.response.oderLiist;

import java.util.List;


public class TasksBeanAdapter extends RecycleListBaseAdapter<oderLiist.TasksBean> {

    private Context mContext;
    private Animation mLikeAnim;
    private onItemClick onItemClick;

    public TasksBeanAdapter(Context context, int layoutId, List<oderLiist.TasksBean> datas, onItemClick onItemClick) {
        super(context, layoutId, datas);
        this.mContext = context;
        mLikeAnim = AnimationUtils.loadAnimation(context, R.anim.anim_like);
        this.onItemClick = onItemClick;
    }

    @Override
    public void convert(RecycleBaseViewHolder helper, oderLiist.TasksBean tiktokBean, int position) {

        TextView tv_state = (TextView) helper.getView(R.id.tv_state);
//        2黄3红4绿
        switch (tiktokBean.getStatus()) {
            case 1:
                tv_state.setTextColor(mContext.getResources().getColor(R.color.text_color_black));
                tv_state.setText("待接收");
                break;
            case 2:
                tv_state.setTextColor(mContext.getResources().getColor(R.color.text_color_audit));
                tv_state.setText("待完成");
                break;
            case 3:
                tv_state.setTextColor(mContext.getResources().getColor(R.color.text_color_error));
                tv_state.setText("取消中");
                break;
            case 4:
                tv_state.setTextColor(mContext.getResources().getColor(R.color.text_color_pass));
                tv_state.setText("完成");
                break;
        }

        helper.setText(R.id.tv_name, tiktokBean.getNickname());
        helper.setText(R.id.tv_bianhao, "编号：" + tiktokBean.getId());
        helper.setText(R.id.tv_time, tiktokBean.getCreatetime());
        helper.setText(R.id.tv_number, "数量" + tiktokBean.getNums());
        helper.setText(R.id.tv_money, tiktokBean.getZje() + "");
        helper.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onItemClick.onItemClick(position);
            }
        });
    }

    @Override
    public void convert(RecycleBaseViewHolder helper, oderLiist.TasksBean tiktokBean, List<Object> payloads, int position) {
        Log.d("Debug", "到达局部刷新这里-------------------->>>>payloads" + payloads);
    }


    public interface onItemClick {
        void onItemClick(int position);
    }
}
